# -*- coding: utf-8 -*-
# @Time    : 2022/7/16 17:20
# @Author  : catherine
# @Email   : catherine_csq@163.com
# @File    : edit_contacts_page.py
# @Software: PyCharm
from time import sleep

from selenium.webdriver.common.by import By

from pages.base_page import BasePage


class EditContactsPage(BasePage):
    '''编辑联系人界面类'''
    url='http://192.168.189.1:8081/crm/index.php?m=contacts&a=edit&id=12'
    #定位器
    name_locator = (By.ID, 'name')
    email_locator = (By.NAME, 'email')
    position_locator = (By.NAME, 'post')
    qq_no_locator = (By.NAME, 'qq_no')
    save_edit_contacts_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td[2]/input[1]')

    def edit_name(self,name):
        '''编辑姓名'''
        self.find_element(self.name_locator).clear()
        self.find_element(self.name_locator).send_keys(name)

    def edit_email(self,email):
        '''编辑邮箱'''
        self.find_element(self.email_locator).clear()
        self.find_element(self.email_locator).send_keys(email)

    def edit_position(self,position):
        '''编辑职位'''
        self.find_element(self.position_locator).clear()
        self.find_element(self.position_locator).send_keys(position)

    def edit_qq_no(self,qq_no):
        '''编辑QQ'''
        self.find_element(self.qq_no_locator).clear()
        self.find_element(self.qq_no_locator).send_keys(qq_no)

    def click_save_edit_contacts(self):
        '''保存编辑联系人'''
        self.find_element(self.save_edit_contacts_locator).click()


